package scripts.batallasDeRobots;

import org.apache.log4j.Logger;


public class batallasDeRobots {

	Logger logger = Logger.getLogger( this.getClass());


	public String ProcesarBatalla(int num){
		String res = "";
		logger.info( "Comienza metodo para procesar las batallas" );
		
		switch ( num ) {
		case 1:
			res = this.batalla1();
			break;
		case 2:
			res = this.batalla2();
			break;
		case 3:
			res = this.batalla3();
			break;
		case 4:
			res = this.batalla4();
			break;
		case 5:
			res = this.batalla5();
			break;
		case 6:
			res = this.batalla6();
			break;
		case 7:
			res = this.batalla7();
			break;
		case 8:
			res = this.batalla8();
			break;
		default:
			break;
		}
		logger.info( "Metodo ProcesarBatalla finalizado con exito" );
		return res;
	}

	public String batalla1() {

		String batalla = "batalla(){\n\tfor (;;)\n\t{\n\t\twalk()\n\t\t" +
		"if (isStanding()){\n\t\t\trotate(getDirection() + Pi/4)\n\t\t\twait(0.04)\n\t\t\twalk()}\n\t}\n}";

		return batalla;
	}
	public String batalla2() {

		String batalla = "batalla(){\n\tnew float:rotacionRobot = Pi/4\n\tfor (;;)\n\t{\n\t\twalk()\n\t\t" +
		"if (isStanding()){\n\t\t\trotate(getDirection() + Pi/4)\n\t\t\twait(0.04)\n\t\t\twalk()}\n\t\t"+
		"if (getBulletLoad() != 0)\n\t\t{\n\t\t\tshootBullet()\n\t\t}\n\t\t" +
		"if ((getGrenadeLoad() != 0) && (distance <= 50.0) && (distance >= 35))\n\t\t{"+
		"\n\t\t\tlaunchGrenade()\n\t\t}\n\t\tif ((getBulletLoad() == 0) && (getGrenadeLoad() == 0)){" +
		"\n\t\t\trotate(getDirection()- rotacionRobot)\n\t\t\trun()\n\t\t}\n\t}\n}";

		return batalla;
	}
	public String batalla3() {

		String batalla = "batalla(){\n\tnew float:rotacionRobot = Pi/4\n\tfor (;;)\n\t{\n\t\twalk()\n\t\t" +
		"if (isStanding()){\n\t\t\trotate(getDirection() + Pi/4)\n\t\t\twait(0.04)\n\t\t\twalk()}\n\t\t"+
		"new itemWatch = ITEM_ENEMY|ITEM_WARRIOR\n\t\tnew float:distance = 0.0\n\t\t"+
		"new float:yaw\n\t\tnew float:pitch\n\t\twatch(itemWatch,distance,yaw,pitch)\n\t\t"+
		"rotate(getDirection()+getTorsoYaw()+getHeadYaw()+yaw)\n\t\trotateTorso(0.0)\n\t\t"+
		"if (getBulletLoad() != 0)\n\t\t{\n\t\t\tshootBullet()\n\t\t}\n\t\t" +
		"if ((getGrenadeLoad() != 0) && (distance <= 50.0) && (distance >= 35))\n\t\t{"+
		"\n\t\t\tlaunchGrenade()\n\t\t}\n\t\tif ((getBulletLoad() == 0) && (getGrenadeLoad() == 0)){" +
		"\n\t\t\trotate(getDirection()- rotacionRobot)\n\t\t\trun()\n\t\t}\n\t}\n}";

		return batalla;
	}
	public String batalla4() {

		String batalla = "batalla(){\n\tnew float:rotacionRobot = Pi/4\n\tfor (;;)\n\t{\n\t\twalk()\n\t\t" +
		"if (isStanding()){\n\t\t\trotate(getDirection() + Pi/4)\n\t\t\twait(0.04)\n\t\t\twalk()}\n\t\t"+
		"new itemWatch = ITEM_ENEMY|ITEM_WARRIOR\n\t\tnew float:distance = 0.0\n\t\t"+
		"new float:yaw\n\t\tnew float:pitch\n\t\twatch(itemWatch,distance,yaw,pitch)\n\t\t"+
		"if (itemWatch == ITEM_ENEMY|ITEM_WARRIOR)\n\t\t{\n\t\t\trotate(getDirection()+getTorsoYaw()+getHeadYaw()+yaw)\n\t\t\trotateTorso(0.0)\n\t\t\t"+
		"if (getBulletLoad() != 0)\n\t\t\t{\n\t\t\t\tshootBullet()\n\t\t\t}\n\t\t\t" +
		"if ((getGrenadeLoad() != 0) && (distance <= 50.0) && (distance >= 35))\n\t\t\t{"+
		"\n\t\t\t\tlaunchGrenade()\n\t\t\t}\n\t\t\tif ((getBulletLoad() == 0) && (getGrenadeLoad() == 0)){" +
		"\n\t\t\t\trotate(getDirection()- rotacionRobot)\n\t\t\t\trun()\n\t\t\t}\n\t\t}\n\t}\n}";

		return batalla;
	}
	public String batalla5() {

		String batalla = "batalla(){\n\tnew float:rotacionRobot = Pi/4\n\tfor (;;)\n\t{\n\t\twalk()\n\t\t" +
		"if (isStanding()){\n\t\t\trotate(getDirection() + Pi/4)\n\t\t\twait(0.04)\n\t\t\twalk()}\n\t\t"+
		"new itemWatch = ITEM_ENEMY|ITEM_WARRIOR\n\t\tnew float:distance = 0.0\n\t\t"+
		"new float:yaw\n\t\tnew float:pitch\n\t\twatch(itemWatch,distance,yaw,pitch)\n\t\t"+
		"if (itemWatch == ITEM_ENEMY|ITEM_WARRIOR)\n\t\t{\n\t\t\trotate(getDirection()+getTorsoYaw()+getHeadYaw()+yaw)\n\t\t\trotateTorso(0.0)\n\t\t\t"+
		"new itemAim\n\t\t\taim(itemAim)\n\t\t\tif(itemAim == ITEM_ENEMY|ITEM_WARRIOR)\n\t\t\t{\n\t\t\t\t"+ 
		"if (getBulletLoad() != 0)\n\t\t\t\t{\n\t\t\t\t\tshootBullet()\n\t\t\t\t}\n\t\t\t\t" +
		"if ((getGrenadeLoad() != 0) && (distance <= 50.0) && (distance >= 35))\n\t\t\t\t{"+
		"\n\t\t\t\t\tlaunchGrenade()\n\t\t\t\t}\n\t\t\t\tif ((getBulletLoad() == 0) && (getGrenadeLoad() == 0)){" +
		"\n\t\t\t\t\trotate(getDirection()- rotacionRobot)\n\t\t\t\t\trun()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}";

		return batalla;
	}
	public String batalla6() {

		String batalla = "batalla(){\n\tnew float:rotacionRobot = Pi/4\n\tfor (;;)\n\t{\n\t\twalk()\n\t\t" +
		"if (isStanding()){\n\t\t\trotate(getDirection() + Pi/4)\n\t\t\twait(0.04)\n\t\t\twalk()}\n\t\t"+
		"new itemWatch = ITEM_ENEMY|ITEM_WARRIOR\n\t\tnew float:distance = 0.0\n\t\t"+
		"new float:yaw\n\t\tnew float:pitch\n\t\twatch(itemWatch,distance,yaw,pitch)\n\t\t"+
		"if (itemWatch == ITEM_ENEMY|ITEM_WARRIOR)\n\t\t{\n\t\t\trotate(getDirection()+getTorsoYaw()+getHeadYaw()+yaw)\n\t\t\trotateTorso(0.0)\n\t\t\t"+
		"new itemAim\n\t\t\taim(itemAim)\n\t\t\tif(itemAim == ITEM_ENEMY|ITEM_WARRIOR)\n\t\t\t{\n\t\t\t\t"+ 
		"if (getBulletLoad() != 0)\n\t\t\t\t{\n\t\t\t\t\tshootBullet()\n\t\t\t\t}\n\t\t\t\t" +
		"if ((getGrenadeLoad() != 0) && (distance <= 50.0) && (distance >= 35))\n\t\t\t\t{"+
		"\n\t\t\t\t\tlaunchGrenade()\n\t\t\t\t}\n\t\t\t\tif ((getBulletLoad() == 0) && (getGrenadeLoad() == 0)){" +
		"\n\t\t\t\t\trotate(getDirection()- rotacionRobot)\n\t\t\t\t\trun()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t"+
		"else {\n\t\t\tnew sound\n\t\t\tnew itemHear = ITEM_ENEMY|ITEM_WARRIOR\n\t\t\tnew float:yawHear\n\t\t\t" +
		"hear(itemHear, sound, yawHear)\n\t\t\tif(itemHear == ITEM_ENEMY|ITEM_GUN) {\n\t\t\t\trotate(getDirection() + yawHear)\n\t\t\t\t"+
		"wait(0.5)\n\t\t\t}\n\t\t}\n\t}\n}";

		return batalla;
	}
	public String batalla7() {

		String batalla = "batalla(){\n\tnew float:rotacionRobot = Pi/4\n\tnew float:rotacionTorsoRobot = 1.047\n\tfor (;;)\n\t{\n\t\twalk()\n\t\t" +
		"if (isStanding()){\n\t\t\trotate(getDirection() + Pi/4)\n\t\t\twait(0.04)\n\t\t\twalk()}\n\t\t"+
		"new itemWatch = ITEM_ENEMY|ITEM_WARRIOR\n\t\tnew float:distance = 0.0\n\t\t"+
		"new float:yaw\n\t\tnew float:pitch\n\t\twatch(itemWatch,distance,yaw,pitch)\n\t\t"+
		"if (itemWatch == ITEM_ENEMY|ITEM_WARRIOR)\n\t\t{\n\t\t\trotate(getDirection()+getTorsoYaw()+getHeadYaw()+yaw)\n\t\t\trotateTorso(0.0)\n\t\t\t"+
		"new itemAim\n\t\t\taim(itemAim)\n\t\t\tif(itemAim == ITEM_ENEMY|ITEM_WARRIOR)\n\t\t\t{\n\t\t\t\t"+ 
		"if (getBulletLoad() != 0)\n\t\t\t\t{\n\t\t\t\t\tshootBullet()\n\t\t\t\t}\n\t\t\t\t" +
		"if ((getGrenadeLoad() != 0) && (distance <= 50.0) && (distance >= 35))\n\t\t\t\t{"+
		"\n\t\t\t\t\tlaunchGrenade()\n\t\t\t\t}\n\t\t\t\tif ((getBulletLoad() == 0) && (getGrenadeLoad() == 0)){" +
		"\n\t\t\t\t\trotate(getDirection()- rotacionRobot)\n\t\t\t\t\trun()\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t"+
		"else {\n\t\t\tnew sound\n\t\t\tnew itemHear = ITEM_ENEMY|ITEM_WARRIOR\n\t\t\tnew float:yawHear\n\t\t\t" +
		"hear(itemHear, sound, yawHear)\n\t\t\tif(itemHear == ITEM_ENEMY|ITEM_GUN) {\n\t\t\t\trotate(getDirection() + yawHear)\n\t\t\t\t"+
		"wait(0.5)\n\t\t\t}\n\t\t\trotateTorso(rotacionTorsoRobot)\n\t\t\tif(getTorsoYaw() == rotacionTorsoRobot){\n\t\t\t\t"+
		"rotacionTorsoRobot = (rotacionTorsoRobot * (-1))}\n\t\t}\n\t}\n}";

		return batalla;
	}
	public String batalla8() {

		String batalla = "batalla(){\n\tnew float:rotacionTorsoRobot = 1.047\n\tfor (;;)\n\t{\n\t\twalk()\n\t\t" +
		"if (isStanding()){\n\t\t\trotate(getDirection() + Pi/4)\n\t\t\twait(0.04)\n\t\t\twalk()\n\t\t}\n\t\t\t"+
		"rotateTorso(rotacionTorsoRobot)\n\t\t\tif(getTorsoYaw() == rotacionTorsoRobot){\n\t\t\t\t"+
		"rotacionTorsoRobot = (rotacionTorsoRobot * (-1))}\n\t}\n}";

		return batalla;
	}

}
